import os

from dotenv import load_dotenv

from src.common_tools import getAgent, chat, query_weather, writeFile, python_inter, fig_inter, sql_inter, extract_data, \
    get_answer, get_answer_github, save_markdown_to_file

load_dotenv(override=True)

os.environ['HTTP_PROXY'] = 'http://127.0.0.1:10809'
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:10809'

async def getWeather():
    tools = [query_weather]
    agent = getAgent("你是一个助人为乐的助手",tools)
    await chat(agent)

async def test_nostop_loop():
    tools = [writeFile]
    agent = getAgent("你是一个助人为乐的助手",tools)
    await chat(agent)

async def test_function_tools():
    tools = [query_weather,python_inter,fig_inter,sql_inter,extract_data,get_answer,get_answer_github]
    agent = getAgent("你是一个助人为乐的助手",tools)
    await chat(agent)


#########################################################

def test_write_to_file():
    save_markdown_to_file(content="测试文档", filename_hint="测试文档创建", directory="research_task")


if __name__ == "__main__":
    import asyncio
    # asyncio.run(getWeather())
    #asyncio.run(test_nostop_loop())
    asyncio.run(test_function_tools())